import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'plugin_secure_store_platform_interface.dart';

/// An implementation of [PluginSecureStorePlatform] that uses method channels.
class MethodChannelPluginSecureStore extends PluginSecureStorePlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('plugin_secure_store');

  @override
  Future<String?> generateRSA(String alias) async {
    final pubKey = await methodChannel.invokeMethod<String>('generateRSA', {'alias':alias});
    return pubKey;
  }

  @override
  Future<String?> encryptRSA(String alias, String content) async {
    final resultEncrypt = await methodChannel.invokeMethod<String>('encryptRSA', {'alias':alias, "content":content});
    return resultEncrypt;
  }

  @override
  Future<String?> decryptRSA(String alias, String content) async {
    final resultDecrypt = await methodChannel.invokeMethod<String>('decryptRSA', {'alias':alias, "content":content});
    return resultDecrypt;
  }

  @override
  Future<String?> decryptBigRSA(String alias, String content) async {
    final resultDecrypt = await methodChannel.invokeMethod<String>('decryptBigRSA', {'alias':alias, "content":content});
    return resultDecrypt;
  }
}
